package com.haois.ws.common.exception;

import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * Created by RuiHaoZ on 2018/3/10 19:24
 */
public class GetModelAndView {

    public static ModelAndView getPage(String title, String subTitle, String tips) {
        ModelAndView mv = new ModelAndView("/error");
        mv.addObject("title", title);
        mv.addObject("subTitle", subTitle);
        mv.addObject("tips", tips);
        return mv;
    }

    public static ModelAndView getPage(String viewName, String title, String subTitle, String tips) {
        ModelAndView mv = new ModelAndView(viewName);
        mv.addObject("title", title);
        mv.addObject("subTitle", subTitle);
        mv.addObject("tips", tips);
        return mv;
    }

    public static ModelAndView getErrorPage() {
        return getPage("抱歉！您访问的页面出现异常", "请稍后重试或联系管理员", "");
    }

    public static ModelAndView getSessionOutPage() {
        return getPage("抱歉！当前会话已过期", "请重新打开页面", "");
    }

    public static ModelAndView getDataErrorPage() {
        return getPage("抱歉！您访问的数据出现异常", "请稍后重试或联系管理员", "");
    }

    public static ModelAndView get404Page() {
        return getPage("404", "找不到", "");
    }

    public static ModelAndView getBasePage(Map<String, Object> params, String page) {
        ModelAndView mv = new ModelAndView(page);
        mv.addAllObjects(params);
        return mv;
    }

}
